package test2.experiment8;

import java.io.*;

public class FileTest {
    public static void main(String[] args) {
        FileOutputStream fileOutputStream = null;
        try {
            fileOutputStream = new FileOutputStream("input.txt");
            byte[] buffer = new byte[1024];
            int len = 0;
            while ((len = System.in.read(buffer)) != -1) {
                String str = new String(buffer, 0, len);
                if ("quit\n".equals(str)) {
                    break;
                }
                fileOutputStream.write(buffer, 0, len);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (fileOutputStream != null) {
                try {
                    fileOutputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
